package com.neusoft.a132wxyorderingdish.fragments;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.neusoft.a132wxyorderingdish.R;
import com.neusoft.a132wxyorderingdish.adapter.CollectAdapter;
import com.neusoft.a132wxyorderingdish.beans.CollectBean;
import com.neusoft.a132wxyorderingdish.listener.RetrofitListener;
import com.neusoft.a132wxyorderingdish.model.ShopModel;

import java.util.List;

public class CollectShopFragment extends BaseFragment implements RetrofitListener<List<CollectBean>> {
    private RecyclerView recyclerView;
    private CollectAdapter collectAdapter;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        setLayout_file(R.layout.fragment_collect_shop);
        return super.onCreateView(inflater, container,savedInstanceState);
    }


    @Override
    void initView() {

        recyclerView=view.findViewById(R.id.collect_rv);
        if(getActivity()!=null){
            LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
            //设置垂直布局
            layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            //设置布局管理器
            recyclerView.setLayoutManager(layoutManager);
        }
    }

    @Override
    void initEvent() {

    }

    @Override
    void initData() {

        ShopModel shopModel=new ShopModel();
        shopModel.getAllUserCollection(getUser_id(),"0",this);
    }

    @Override
    public void onSuccess(List<CollectBean> collectBeans, int flag) {
        collectAdapter=new CollectAdapter(getActivity(),collectBeans);
        recyclerView.setAdapter(collectAdapter);
    }

    @Override
    public void onFail() {

    }
}

